package com.serv.common.model.sys;

import java.util.List;

import com.serv.common.base.BaseModel;
import com.serv.util.Consumer;

@SuppressWarnings("serial")
public class Role extends BaseModel<Role> {
	public static Role dao = new Role().dao();
	
	public List<Permission> permissions(){
		String sql = "select P.* from sys_role_permission RP left join sys_permission P on RP.permission_id=P.id where RP.role_id=?";
		return Permission.dao.find(sql,get("id"));
	}
	
	public Consumer used(){
		return Consumer.NEW(get("used_by"));
	}
	
	public Consumer owned(){
		return Consumer.NEW(get("owned_by"));
	}
}
